<!Doctype html>
<html>

<head>
    <title>oixan的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html"  charset="utf-8">
    <meta name="referrer" content="no-referrer" />
    <link rel="stylesheet" type="text/css" href="../css/blog.css">

</head>

<body>
    <div class="head">
        <div class="headnav">
            <div class="naveframe">
                <ul class="navlist">
                    <li>
                        <a href="../index.html">
                            主页
                        </a>
                    </li>
                    <li>
                        <a href="../bloglist.html">
                            博客
                        </a>
                    </li>
                    <li>
                        <a href="../about.html">
                            关于
                        </a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="headtext">
            <div class="headtext1">世界很简单，人类很复杂。</div>
            <div class="headtext2">浮生若梦，寻寻觅觅。</div>
        </div>
    </div>

    <div class="contents-all">
        <div class="contents">

            <div class="frame">
                <div class="title">
                    <h3>vba设置excel密码</h3>
                </div>
                <div class="dtime">时间：2018-10-29</div>
                <div class="detail">
      
                    <p>
                        Sub userpw()
                    </p>
                    <p>
                        Dim pw As Workbook
                    </p>
                    <p>
                        Set pw = Application.ActiveWorkbook
                    </p>
                    <p>
                        pw.Password = InputBox(&quot;输入密码&quot;)
                    </p>
                    <p>
                        pw.Close
                    </p>
                    <p>
                        End Sub
                    </p>
                    <p>
                        <br/>
                    </p>
                    <p>导入图片</p>
<p>
    Sub pic_insert()
</p>
<p>
    Dim i As Integer
</p>
<p>
    Dim filepath As String
</p>
<p>
    &#39;Dim insertlumn As String
</p>
<p>
    Application.ScreenUpdating = False &#39;关闭屏幕更新
</p>
<p>
    &#39;insertlumn = ActiveSheet.TextBox1.Text
</p>
<p>
    &#39;If insertlumn = &quot;&quot; Then
</p>
<p>
    &#39;MsgBox (&quot;输入内容&quot;)
</p>
<p>
    &#39;Exit Sub
</p>
<p>
    &#39;End If
</p>
<p>
    For i = 1 To Range(&quot;A65536&quot;).End(xlUp).Row &#39;取得行
</p>
<p>
    filepath = Dir(&quot;D:\mycodes\&quot; &amp; Cells(i, 1).Text &amp; &quot;.*&quot;)
</p>
<p>
    ext_name = &quot;.&quot; &amp; Split(filepath, &quot;.&quot;)(1) &#39;不同扩展图
</p>
<p>
    filepath = &quot;D:\mycodes\&quot; &amp; Cells(i, 1).Text &amp; ext_name&nbsp; &#39;取得图路径
</p>
<p>
    If Dir(filepath) &lt;&gt; &quot;&quot; Then
</p>
<p>
    With ActiveSheet.Range(&quot;b&quot; &amp; i) &#39;插入到单元格
</p>
<p>
    ActiveSheet.Shapes.AddPicture filepath, False, True, .Left, .Top, .Width, .Height
</p>
<p>
    On Error Resume Next &#39;忽略错误继续运行
</p>
<p>
    End With
</p>
<p>
    End If
</p>
<p>
    Next
</p>
<p>
    Application.ScreenUpdating = True &#39;开启屏幕更新
</p>
<p>
    End Sub
</p>
<p>
    <br/>
</p>
    
          
              </div>
                <a href="javascript:void(0)" onclick="showPg()">返回</a>
            </div>

        </div>
    </div>
    <div class="footer">
        <div class="footertext">©2018,oixan博客</div>
    </div>
    <span id="backtop" onclick="topFunction()">返回顶部</span>
    
</body>
<script  src="../js/fanhuiye.js"></script>

</html>